package com.course.mapper;

import com.course.entity.Teacher;
import com.course.vo.Courseinfo;
import com.course.vo.SumAndAvg;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TeacherMapper {
    /**
     * 分页查询
     * @param tno
     * @param tname
     * @return
     */
     List<Teacher> page(@Param("tno") String tno, @Param("tname") String tname);

    /**
     * 插入新的教师数据
     * @param teacher
     */
    @Insert("insert into teacher(tno,tname,tjob,tsalary)"+
    "values "+"(#{tno},#{tname},#{tjob},#{tsalary})")
    void addTeacher(Teacher teacher);

    /**
     * 根据教工号查询教工
     * @param tno
     * @return
     */
    @Select("select * from teacher where tno=#{tno}")
    List<Teacher> searchByTno(String tno);

    /**
     * 根据教工号删除教工
     * @param tno
     */
    @Delete("delete from teacher where tno=#{tno}")
    void deleteByTno(String tno);

    /**
     * 更新教师信息
     * @param teacher
     */
    void update(Teacher teacher);

    /**
     * 查询各职称教师人数，以及平均工资
     * @return
     */
    @Select("select sumteacher,avgsal,tjob from teacherinfo")
    List<SumAndAvg> sumAndAvg();

    /**
     * 所教课程的最高分以及平均分，最低分
     * @return
     */
    @Select("select tname, cname, avggrade, maxgrade, mingrade from courseinfo")
    List<Courseinfo> courseinfo();

    /**
     * 教师登录
     * @param teacher
     * @return
     */
    @Select("select * from teacher where username=#{username} and password=#{password}")
    Teacher getByUsernameAndPassword(Teacher teacher);

    /**
     * 查询所有教师数据
     * @return
     */
    @Select("select * from teacher")
    List<Teacher> allteacher();
}
